'''
Author: your name
Date: 2020-10-28 14:44:57
LastEditTime: 2020-10-28 15:16:08
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python-study\博客学习\进阶\读取文件.py
'''
class Student(object):
    def PrintName(self):
        if(func(self)):
            print(self.Name)

def ReadFileToStudent(ls):
    f=open('record.txt','r+')
    for l in f.readlines():
        student= Student()
        res=l.strip('\n').split(',')
        student.Name=res[0]
        student.Age=int(res[1])
        student.Score=int( res[2])
        ls.append(student)


def UpdaFileContent(func):
    with open('record.txt', 'r', encoding='utf8') as rf:
        lines = rf.readlines()
    with open('record.txt', 'w', encoding='utf8') as wf:
        for (index, line) in enumerate(lines):
            if func(line):
                lines[index] = line.capitalize()
        wf.writelines(lines)

def judgeIsTitle(content):
    if content.istitle():
        return False
    return True

def func(student):
    if student.Score < 60:
        return True
    else:
        return False

if __name__ == "__main__":
    l=[]
    ReadFileToStudent(l)
    for s in l:
        s.PrintName()
    UpdaFileContent(judgeIsTitle)